<?php

 $this->title ="航线销售列表";

?>

<?= yii\web\View::registerCssFile("/css/front/sale-list.css",['depends' => 'app\assets\MuiAsset']) ?>
<style type="text/css">
	.text-center{text-align: center;}
	.mui-pagination>li>a, .mui-pagination>li>span{color: #a664a6;}
    .mui-pagination>li.mui-active>a, .mui-pagination>li.mui-active>a:active, .mui-pagination>li.mui-active>span, .mui-pagination>li.mui-active>span:active, .mui-pagination>li:active>a, .mui-pagination>li:active>a:active, .mui-pagination>li:active>span, .mui-pagination>li:active>span:active{border-color: #a664a6;background-color: #a664a6;}	
</style>

<div class="mui-content">

		<?php foreach($list as $model){ ?>
		<div class="info">
			<div id="t_<?=$model->id?>" class="tl" data-key="<?=$model->id?>"></div>
			<a href="/front/default/sale-detail?id=<?=$model->id?>">
				<div class="tr">
					<p><?=$model->name?></p>
					<p class="mui-col-xs-6">总金额：<span><?=$model->allOrderPrice?></span></p>
					<p class="mui-col-xs-5"><?=$model->go_time?> 起航</p>
				</div>
			</a>
				<div class="mui-row bt">
					<p class="mui-col-sm-6 bl">舱房数：<span>
					<?php if($model->stock == 1){
							$n = $model->stockAll-$model->surplusStock;
                    		echo sprintf("%s/%s", $n ,$model->stockAll);
						  }else{
							$n = $model->stockAll2-$model->surplusStock;
                    		echo sprintf("%s/%s", $n ,$model->stockAll2);
						  } ?></span>
					</p>
					<p class="mui-col-sm-6 br">剩余<span>
							<?=round((strtotime($model->go_time)-time())/3600/24)?>
							</span>天</p>
				</div>
			
		</div>
		<?php }?>
		<div class="mui-content-padded text-center">
		<?= yii\widgets\LinkPager::widget(['pagination' => $pages,'lastPageLabel'=>false, 'firstPageLabel'=>false,'maxButtonCount'=>5,'activePageCssClass'=>'mui-active','disabledPageCssClass'=>'mui-disabled','nextPageLabel' => false,
			'prevPageLabel' => false,'linkOptions'=>['data-in'=>'s1'],'options'=>['class'=>'mui-pagination']]); ?>
		</div>
</div>	


<?= yii\web\View::registerJsFile("/js/front/echarts.common.min.js",['depends' => 'app\assets\MuiAsset']) ?>
<?php app\components\JsBlock::begin() ?>
<script type="text/javascript">  
var data = <?=json_encode($data)?>;
var order_status = <?=json_encode($order_status)?>;

$(".tl").each(function(){
	var key = $(this).attr("data-key");
	var id = $(this).attr("id");

	var data_value = [];
	$.each(data[key],function(i,n){
		var value_name = {"value":n,"name":order_status[i]};
		data_value.push(value_name);
	});
	
	var myChart = echarts.init(document.getElementById(id));
	var option = {
	    tooltip : {
	    	position: [150,50],
	        trigger: 'item',
	        formatter: "{a} <br/>{b} : {c} ({d}%)"
	    },
	   
	    series : [
	        {
	            name: '房间占比',
	            type: 'pie',
	            radius : '65%',
	            center: ['40%', '45%'],           
	            label: {
	            	normal:{
	            		show: false
	            	}
	            },
	            data:data_value,
	            itemStyle: {
	                emphasis: {
	                    shadowBlur: 10,
	                    shadowOffsetX: 0,
	                    shadowColor: 'rgba(0, 0, 0, 0.5)'
	                }
	            }
	        }
	    ]
	};
	myChart.setOption(option);

});



</script>
<?php app\components\JsBlock::end() ?>

